﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using Caliburn.Micro;
using System.Dynamic;
using System.Windows;
using Light.Shared;

namespace Light.ViewModels
{
    [Export(typeof(ShellViewModel))]
    public class ShellViewModel : PropertyChangedBase, IHaveDisplayName
    {
        private string _displayName = "Light";

        public string DisplayName
        {
            get { return _displayName; }
            set { _displayName = value;
                NotifyOfPropertyChange(() => this.DisplayName);
            }
        }
        [Import]
        private Shared.Interfaces.IPlugin plugin;

        private readonly IWindowManager _windowManager;

        [ImportingConstructor]
        public ShellViewModel(IWindowManager windowManager)
        {
            _windowManager = windowManager;
        }

        public void OpenWindow()
        {
            dynamic settings = new ExpandoObject();
            settings.WindowStartupLocation = WindowStartupLocation.Manual;

            _windowManager.ShowWindow(new ShellViewModel(_windowManager), null, settings);


            if (plugin != null)
                DisplayName = plugin.GetName();
        }

        public void OpenSettings()
        {
            IsSettingsFlyoutOpen = true;
        }

        private bool _isSettingsFlyoutOpen;

        public bool IsSettingsFlyoutOpen
        {
            get { return _isSettingsFlyoutOpen; }
            set
            {
                _isSettingsFlyoutOpen = value;
                NotifyOfPropertyChange(() => IsSettingsFlyoutOpen);
            }
        }
    }
}
